package com.soul.common.bean.vo;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;

import java.util.*;

/**
 * @author Shiws
 * @version 1.0
 * @date 2023/11/20 18:29
 */
@Data
public class BaseDataVo {

    private Set<Long> userIds = new HashSet<>();


    private Map<Long,UserVo> userVoMap = new HashMap<>();

    private Set<String> dictTypes = new HashSet<>();

    private Map<String, Map<String, DictionaryVo>> dictVoMap = new LinkedHashMap<>();

    private Set<Long> fileIds = new HashSet<>();

    private Map<Long,FileVo> fileVoMap = new HashMap<>();

    public BaseDataVo addUserId(Long ...userId){
        if (ObjectUtil.isNotEmpty(userId)){
            userIds.addAll(Arrays.asList(userId));
        }
        return this;
    }

    public BaseDataVo addUserId(List<Long> userId){
        if (ObjectUtil.isNotEmpty(userId)){
            userIds.addAll(userId);
        }
        return this;
    }

    public BaseDataVo addDictType(String ...dictType){
        if (ObjectUtil.isNotEmpty(dictType)){
            dictTypes.addAll(Arrays.asList(dictType));
        }
        return this;
    }

    public DictionaryVo getDictVo(String dictType,String dictCode){
        Map<String, DictionaryVo> stringDictionaryVoMap = this.dictVoMap.get(dictType);
        if (ObjectUtil.isNotEmpty(stringDictionaryVoMap)){
            return stringDictionaryVoMap.get(dictCode);
        }
        return null;
    }

    public BaseDataVo addFileId(Long ...fileId){
        if (ObjectUtil.isNotEmpty(fileId)){
            fileIds.addAll(Arrays.asList(fileId));
        }
        return this;
    }

    public BaseDataVo addFileId(List<Long> fileId){
        if (ObjectUtil.isNotEmpty(fileId)){
            fileIds.addAll(fileId);
        }
        return this;
    }

    public FileVo getFileVo(Long fileId){
        return this.fileVoMap.get(fileId);
    }

    public UserVo getUserVo(Long userId){
        return this.userVoMap.get(userId);
    }
}
